﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>创建考场</title>
    <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery-1.5.2.min.js" type="text/javascript"></script>
    <link href="../css/jquery.loadmask.css" rel="stylesheet" type="text/css" />
    <script src="../js/ligerui.min.js" type="text/javascript"></script>
    <script src="../Js/json2.js" type="text/javascript"></script>
    <script src="../Js/jquery.loadmask.min.js" type="text/javascript"></script>
    <script src="../Js/conmon.js" type="text/javascript"></script>
    <script type="text/javascript">
        var modelID;
        var pWind;
        $(function () {
            pWind = parent.window.parent.window.getWindow();
            modelID = (pWind != null ? parseInt(pWind.$("#modelID").val()) : 0);
            if (modelID == 0) {
                showErrorTip("参数错误！");
                return;
            }
            $("#btnClose").click(function () { closeRefresh(false, ""); });
            $("#lblModelName").html(pWind.$("#modelName").val());

            $("#txtPass").ligerSpinner({ width: 95, type: 'int' });
            $("#txtTime").ligerSpinner({ width: 95, type: 'int' });
            $("#txtBeginDate").ligerDateEditor({ showTime: true, format: "yyyy-MM-dd hh:mm" });
            $("#txtEndDate").ligerDateEditor({ showTime: true, format: "yyyy-MM-dd hh:mm" });
        });

        function CheckData() {
            if ($("#txtName").val() == "") {
                showErrorTip("考场名称必须填写！");
                return false;
            }
            if ($("#txtBeginDate").val() == "" || $("#txtEndDate").val() == "") {
                showErrorTip("请填写正确的开考期限");
                return false;
            }
            var time = parseInt($("#txtTime").val());
            var pass = parseInt($("#txtPass").val());
            if (time <= 0) {
                showErrorTip("考试时间不正确，必须大于0分钟！");
                return false;
            }
            if (pass <= 0) {
                showErrorTip("合格率不正确，必须大于0！");
                return false;
            }
            return true;
        }

        function SaveData() {
            if (!CheckData())
                return;
            $("#divContent").mask("数据处理中，请稍候......");
            var examData = { id: 0, name: $("#txtName").val(), model: modelID, begin: $("#txtBeginDate").val(), end: $("#txtEndDate").val(), time: $("#txtTime").val(), pass: $("#txtPass").val() };
            var params = { ExamData: JSON2.stringify(examData) };
            $.getJSON("../WebServer/ExamRoom.ashx?Action=AddExam&rnd=" + Math.random(), params, function (msgData) {
                $("#divContent").unmask();
                if (msgData.IsSuccess == 1) {
                    showAlertOk("保存成功");
                    closeRefresh(false, "");
                    if (pWind) pWind.load_grid();
                }
                else
                    showErrorTip(msgData.Msg);
            });
        }
    </script>
    <style type="text/css">
        .table{background-color:#84A0C4;border:1px solid #84A0C4;}
        .td{background-color:#ffffff;}
    </style>
</head>
<body>
    <div id="divContent">
    <table width="100%" cellpadding="1px" cellspacing="1px" class="table">
        <tr style="height:40px">
            <td colspan="2" align="center" class="td" style="font-weight:bold;">创建考场【<label id="lblModelName"></label>】</td>
        </tr>
        <tr style="height:40px">
            <td class="td" style="width:15%;" align="right">考场名称：</td>
            <td class="td"><input type="text" id="txtName" style="width:95%" class="l-text" /></td>
        </tr>
        <tr style="height:40px">
            <td class="td" align="right">开考期限：</td>
            <td class="td"><div style="float:left"><input type="text" id="txtBeginDate" /></div><div style="float:left">&nbsp;&nbsp;至&nbsp;&nbsp;</div><div style="float:left"><input type="text" id="txtEndDate" /></div></td>
        </tr>
        <tr style="height:40px">
            <td class="td" align="right">考试时间：</td>
            <td class="td">
                <div style="float:left"><input type="text" id="txtTime" style="width:90%" class="l-text" onfocus="this.select();" /></div><div style="float:left">(分钟)</div>
                <div style="float:left">&nbsp;&nbsp;&nbsp;&nbsp;合格率：</div>
                <div style="float:left"><input type="text" id="txtPass" style="width:40%" class="l-text" onfocus="this.select();" /></div><div style="float:left"><span style="color:Red;font-weight:bold;font-size:12pt">%</span></div>
                </td>        
            </tr>
    </table>       
    <table width="100%" cellpadding="0" cellspacing="0" style="height:100%;">
        <tr style="height:60px">
            <td  align="center">
                <input type="button" id="btnPost" value="保存" onclick="SaveData();" class="l-button" style="display:inline" />
                <input type="button" id="btnClose" value="关闭"class="l-button" style="display:inline" />
            </td>
        </tr>    
    </table>     
    </div>
</body>
</html>
